// GetPropertyRegularInfo.cpp: implementation of the GetPropertyRegularInfo class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "phsshare.h"
#include "GetPropertyRegularInfo.h"
#include "GetPropertyFunction.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

GetPropertyRegularInfo::GetPropertyRegularInfo(ModelObject* pObject)
{
	ASSERT(pObject);
	m_pObject = pObject;
	m_pIterator = NULL;
}

GetPropertyRegularInfo::~GetPropertyRegularInfo()
{
	ClearIterator();
}

GetPropertyFunction* GetPropertyRegularInfo::GetFirst()
{
	FunctionStack* pStack = m_pObject->GetFunctionStack();
	ASSERT(pStack);

	FunctionObject* pObject = NULL;

	ClearIterator();

	m_pIterator = pStack->Get(FunctionObject::eGETPROPERTYFUNCTION);
	if(m_pIterator == NULL)
		return NULL;
	
	for(m_pIterator->Begin(); !m_pIterator->End(); m_pIterator->Next())
	{
		pObject = m_pIterator->Get();
		return static_cast<GetPropertyFunction*>(pObject);
	}
	
	ClearIterator();

	return NULL;
}

GetPropertyFunction* GetPropertyRegularInfo::GetNext()
{
	FunctionObject* pObject = NULL;
	ASSERT(m_pIterator);
	for(m_pIterator->Next(); !m_pIterator->End(); m_pIterator->Next())
	{
		pObject = m_pIterator->Get();
		return static_cast<GetPropertyFunction*>(pObject);
	}
	ClearIterator();
	return NULL;
}

void GetPropertyRegularInfo::ClearIterator()
{
	if(m_pIterator != NULL)
	{
		delete m_pIterator;
		m_pIterator = NULL;
	}
}